using FServer.Core.Entities;

namespace FServer.Core.Interfaces;

/// <summary>
/// 版本管理服务接口
/// </summary>
public interface IVersionService
{
    /// <summary>
    /// 获取最新版本信息
    /// </summary>
    /// <param name="clientVersion">客户端当前版本</param>
    /// <param name="platform">平台 (Windows, Android, iOS)</param>
    /// <returns>版本检查结果</returns>
    Task<VersionCheckResult> CheckVersionAsync(string clientVersion, string platform);
    
    /// <summary>
    /// 获取版本更新文件列表
    /// </summary>
    /// <param name="versionId">版本ID</param>
    /// <returns>更新文件列表</returns>
    Task<List<UpdateFile>> GetUpdateFilesAsync(Guid versionId);
    
    /// <summary>
    /// 获取版本信息
    /// </summary>
    /// <param name="versionId">版本ID</param>
    /// <returns>版本信息</returns>
    Task<ClientVersion?> GetVersionAsync(Guid versionId);
    
    /// <summary>
    /// 创建新版本
    /// </summary>
    /// <param name="version">版本信息</param>
    /// <returns>创建的版本</returns>
    Task<ClientVersion> CreateVersionAsync(ClientVersion version);
    
    /// <summary>
    /// 更新版本信息
    /// </summary>
    /// <param name="version">版本信息</param>
    /// <returns>更新后的版本</returns>
    Task<ClientVersion> UpdateVersionAsync(ClientVersion version);
}

/// <summary>
/// 版本检查结果
/// </summary>
public class VersionCheckResult
{
    /// <summary>
    /// 是否需要更新
    /// </summary>
    public bool NeedUpdate { get; set; }
    
    /// <summary>
    /// 是否强制更新
    /// </summary>
    public bool ForceUpdate { get; set; }
    
    /// <summary>
    /// 最新版本信息
    /// </summary>
    public ClientVersion? LatestVersion { get; set; }
    
    /// <summary>
    /// 当前版本信息
    /// </summary>
    public ClientVersion? CurrentVersion { get; set; }
    
    /// <summary>
    /// 更新文件列表
    /// </summary>
    public List<UpdateFile> UpdateFiles { get; set; } = new();
    
    /// <summary>
    /// 更新说明
    /// </summary>
    public string? UpdateDescription { get; set; }
    
    /// <summary>
    /// 错误信息
    /// </summary>
    public string? ErrorMessage { get; set; }
}
